<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //两数之和
        function getSum(n1,n2){
            return n1+n2;
        }
        //使用可变参数
        function getAllSum(){
            let sum=0;
            for(let i = 0;i<arguments.length;i++)sum += arguments[i];
            return sum;
        }
        //测试
        console.log(getAllSum(1,2,3,4,5));
    </script>
</body>
</html>

